// 接口库
import request from '../utils/request';

// 登录
export function login(username,password){
    return request.post('/login',{
        username,
        password,
    })
}

// 注册
export function register(username,nickname,password){
    return request.post('/register',{
        username,
        nickname,
        password,
    })
}

// 获取用户id
export function getUser(){
    const userId=localStorage.getItem('userId')
    return request.get(`/user/${userId}`)
}

// 封装文件上传方式
export function uploadFile(data){
    // 请求方式
    return request.post("/upload",data)
}

// 封装更新用户信息的接口
export function updataUser(data){
    const userId=localStorage.getItem('userId')
    return request.post(`/user_update/${userId}`,data)
}

export function followUser(userId){
    return request.get(`/user_follows/${userId}`)
}

export function cancelFollowUser(userId){
    return request.get(`/user_unfollow/${userId}`)
}

// 点赞接口
export function likesArticleDetail(id){
    return request.get(`/post_like/${id}`)
}

// 收藏/取消文章接口
export function collectArticleDetail(id){
    return request.get(`/post_star/${id}`)
}

// 关注列表接口
export function followList(){
    return request.get(`/user_follows`)
}

// 取消关注
export function unFollow(id){
    return request.get(`/user_unfollow/${id}`)
}

// 收藏文章
export function myStarFollow(){
    return request.get(`/user_star`)
}

// 搜索推荐
export function mySearch(keyword){
    return request.get(`/post_search_recommend`,{
        params:{keyword}
    })
}